package leetcodecompetition.D353;

/**
 * @Author: Siantar
 * @Date: 2023-07-09-11:36
 * @Description: 1.0
 */
public class T6919 {
    public boolean checkArray(int[] nums, int k) {
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] > 0) {
                if (!s(nums, k, i)) {
                    return false;
                }
            }
        }
        return true;
    }

    public boolean s(int[] num, int k, int a) {
        if (a + k - 1 >= num.length) return false;
        int d = num[a];
        for (int i = a; i < a + k; i++) {
            if (num[i] < d) return false;
            num[i] -= d;
        }
        return true;
    }
}
